package com.oop.Updater;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduleUpdater {
    private final ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
    private long delayTime;
    private long period;
    private Updater updater;
    
    public ScheduleUpdater(Updater updater, long delayTime, long period) {
        this.updater = updater;
        this.delayTime = delayTime;
        this.period = period;
    }

    public void start() {
        service.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                updater.update();
            }
        }, delayTime, period, TimeUnit.SECONDS);
    }

    
}
